import sqlite3
# 存储回溯交易记录
conn = sqlite3.connect('database.db')
c = conn.cursor()
c.execute('''CREATE TABLE IF NOT EXISTS strategies
                 (id INTEGER PRIMARY KEY AUTOINCREMENT, components TEXT)''')
conn.commit()
conn.close()

conn = sqlite3.connect('trades.db')
c = conn.cursor()
c.execute('''CREATE TABLE IF NOT EXISTS trades
             (id INTEGER PRIMARY KEY AUTOINCREMENT,
             stock TEXT NOT NULL,
             quantity INTEGER NOT NULL,
             price REAL NOT NULL,
             type TEXT NOT NULL,
             timestamp TEXT NOT NULL)''')
c.execute('''CREATE TABLE IF NOT EXISTS backtest_trades
             (id INTEGER PRIMARY KEY AUTOINCREMENT,
             stock TEXT NOT NULL,
             quantity INTEGER NOT NULL,
             price REAL NOT NULL,
             type TEXT NOT NULL,
             timestamp TEXT NOT NULL,
             backtest_start TEXT NOT NULL,
             backtest_end TEXT NOT NULL)''')
conn.commit()
conn.close()